package com.fimmlps.reronge.dto;

import com.fimmlps.reronge.entity.ActorComment;
import com.fimmlps.reronge.entity.EntryComment;
import com.fimmlps.reronge.entity.EntryTrigger;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class EntryCommentDto {
    private Integer entryCommentId;

    private Integer userId;
    private String userName;
    private String userHeadUrl;

    private Integer entrySingleId;
    private Integer entryCommentTopId;
    private Integer entryCommentToId;
    private String text;
    private LocalDateTime createTime;
    private String removed;

    private ArrayList<EntryCommentDto> replyList;

    public EntryCommentDto(EntryComment comment){
        this.entryCommentId = comment.getEntryCommentId();
        this.userId = comment.getUserId();
        this.entrySingleId = comment.getEntrySingleId();
        this.entryCommentTopId = comment.getEntryCommentTopId();
        this.entryCommentToId = comment.getEntryCommentToId();
        this.text = comment.getText();
        this.createTime = comment.getCreateTime();
        this.removed = comment.getRemoved();
        replyList = new ArrayList<>();
    }

    public EntryCommentDto(ActorComment comment){
        this.entryCommentId = comment.getActorCommentId();
        this.userId = comment.getUserId();
        this.entrySingleId = comment.getActorSingleId();
        this.entryCommentTopId = comment.getActorCommentTopId();
        this.entryCommentToId = comment.getActorCommentToId();
        this.text = comment.getText();
        this.createTime = comment.getCreateTime();
        this.removed = comment.getRemoved();
        replyList = new ArrayList<>();
    }

    public static List<EntryCommentDto> toDtoList(List<EntryComment> list){
        ArrayList<EntryCommentDto> dtoList = new ArrayList<>();
        for(EntryComment comment:list){
            dtoList.add(new EntryCommentDto(comment));
        }
        return dtoList;
    }
}
